package com.samuel.basics.exception;

import com.samuel.basics.enums.ResultEnum;

/**
 * <p>自定义异常</p>
 *
 * @author aneng huang
 * @since 2020-11-30 14:45:22
 */
public class CustomException extends RuntimeException {

    private static final long serialVersionUID = -403309384439625637L;

    /**  状态码 **/
    private final Integer code;

    /** 方法名称 **/
    private final String method;


    /**
     * 自定义异常
     *
     * @param resultEnum 返回枚举对象
     * @param method     方法
     */
    public CustomException(ResultEnum resultEnum, String method) {
        super(resultEnum.getMsg());
        this.code = resultEnum.getCode();
        this.method = method;
    }

    /**
     * @param code    状态码
     * @param message 错误信息
     * @param method  方法
     */
    public CustomException(Integer code, String message, String method) {
        super(message);
        this.code = code;
        this.method = method;
    }

    public Integer getCode() {
        return code;
    }

    public String getMethod() {
        return method;
    }
}
